
package org.streets.eis.ext.analysis.internal.impl;
import org.slf4j.Logger;
import org.streets.commons.util.StringUtils;
import org.streets.database.SQLConnection;
import org.streets.database.datadict.DataDict;
import org.streets.database.datadict.TableRelations;


public class PermitSqlExtenderImpl extends SqlExtenderImpl{
	private static final long serialVersionUID = 1L;
	
	private static final Integer PERMIT_REJECT = 0; //0:禁止；1：只读；2：完全控制
	private static final Integer PERMIT_READONLY = 1; //0:禁止；1：只读；2：完全控制
	private static final Integer PERMIT_ALL = 2; //0:禁止；1：只读；2：完全控制
	private static final String ORGANID = "organid";
	

	
	public PermitSqlExtenderImpl(Logger logger, DataDict dict,TableRelations relations,SQLConnection connection) {
		super(logger, dict,relations,connection);
	}
	
	 
  
	
	 
  
	//权限条件
	protected String buildPermitValueRestriction(Integer...permValues){
		StringBuffer pvs = new StringBuffer();
		for(Integer v : permValues){
			pvs.append(" perm_value = " + StringUtils.quote(v.toString())+" or ");
		}
		
		if (pvs.length() > 3){
			pvs.setLength(pvs.length() - 3);//去掉or
		}

		return pvs.toString();
	}
	
	//角色条件
	protected String buildRoleIdRestriction(String[] roles){
		StringBuffer sb = new StringBuffer();
		for (String role : roles){
			sb.append(" role_id = " + StringUtils.quote(role) + " or ");
		}
		if (sb.length() > 3){
			sb.setLength(sb.length() - 3);//去掉or
		}
	
		return sb.toString();
		
	}
	
 
 
}
